﻿
Public Class OperationConfig
    Implements IConfig
    Private arun As Boolean
    Private numthread As Integer
    Private impdelay As Integer
    Private numretry As Integer
    Private dispwarn As Boolean
    Private isdebug As Boolean
    Private imock As Boolean
    Private verrs As String
    Public Function checkConfig() As Boolean Implements IConfig.checkConfig
        If (numthread <= 0) Then NumberOfThread = 1
        Return True
    End Function

    Public Function loadConfig() As Boolean Implements IConfig.loadConfig
        Autorun = My.Settings.op_autorun
        NumberOfThread = My.Settings.op_threads
        ImportDelay = My.Settings.op_importdelay
        UnsucessfullRetry = My.Settings.op_unsucretry
        DisplayWarning = My.Settings.op_displaywarnign
        DebugMode = My.Settings.op_isdebug
        InternalMock = My.Settings.op_isimock
        Return True
    End Function

    Public Property validationerrors As String Implements IConfig.validationerrors
        Get
            Return verrs
        End Get
        Set(ByVal value As String)
            verrs = value
        End Set
    End Property

    Public Function writeConfig() As Boolean Implements IConfig.writeConfig
        My.Settings.op_autorun = Autorun
        My.Settings.op_displaywarnign = DisplayWarning
        My.Settings.op_importdelay = ImportDelay
        My.Settings.op_threads = NumberOfThread
        My.Settings.op_unsucretry = UnsucessfullRetry
        My.Settings.op_isdebug = DebugMode
        My.Settings.op_isimock = InternalMock
        Return True
    End Function
    

    Public Property Autorun As Boolean
        Get
            Return arun
        End Get
        Set(ByVal value As Boolean)
            arun = value
        End Set
    End Property

    Public Property NumberOfThread As Integer
        Get
            Return numthread
        End Get
        Set(ByVal value As Integer)
            numthread = value
        End Set
    End Property

    Public Property ImportDelay As Integer
        Get
            Return impdelay
        End Get
        Set(ByVal value As Integer)
            impdelay = value
        End Set
    End Property

    Public Property UnsucessfullRetry As Integer
        Get
            Return numretry
        End Get
        Set(ByVal value As Integer)
            numretry = value
        End Set
    End Property

    Public Property DisplayWarning As Boolean
        Get
            Return dispwarn
        End Get
        Set(ByVal value As Boolean)
            dispwarn = value
        End Set
    End Property

    Sub New()
        loadConfig()
    End Sub

    Public Property DebugMode As Boolean
        Get
            Return isdebug
        End Get
        Set(ByVal value As Boolean)
            isdebug = value
        End Set
    End Property

    Public Property InternalMock As Boolean
        Get
            Return imock
        End Get
        Set(ByVal value As Boolean)
            imock = value
        End Set
    End Property
End Class
